
#ifndef RECORD_RECEIPT
#define RECORD_RECEIPT


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include "discount.h"

using namespace std;

class Record_Receipt
{
  private:
    string code;
    string barcode;
    string shortcut;
    string longtitle;

    double quantity;
    double price;
    double sum;
    double dsum;

  public:
      
   vector<Discount> discount;
      
    int auto_scheme;
    int fix_scheme;
    int tax_group;
    int flags; //флаги из БД
  
    double min_price;
 
    bool code_flag; // true - internal code; false - barcode
    bool enable_flag;

    bool allow_reduction;

    /* cyberpay options */
    int operator_id;
    char session[64];
    char account[64];
    char opname[128];
    char errmsg[255];
    double fee;
    /* end cyberpay options */

    Record_Receipt();
    Record_Receipt(const Record_Receipt & r);
    ~Record_Receipt();
    
    Discount * GetDiscountElemRef(int index);

    const char * GetBarcode();
    const char * GetCode();
    const char * GetShortcut();
    const char * GetLongtitle();

    int GetLenghtBarcode();
    int GetLenghtCode();
    int GetLenghtShortcut();
    int GetLenghtLongtitle();

    void Add_Record_Receipt(const char *barcode_str, const char *code_str, const char *shortcut_str, const char *longtitle_str, double quant, double pr, int fls, bool cflag/*code flag = true, if code; false, if bar code*/, int a_sch, int f_sch, int t_gr, double m_pr, int op_id, const char *acc, double f);
    
    int Add_Sum_Discount(int i, double s, const char * code, const char *name, const char *shortcut, bool manual_fl, int control_min_price);
    int Add_Percent_Discount(int i, double p, const char * code, const char *name, const char *shortcut, bool manual_fl, int control_min_price); 
    
    double RecalculationDiscounts(double s);
    double RecalculationDiscounts();
    
    void SetPrice(double p);
    double GetPrice();

    void SetQuantity(double q);
    double GetQuantity();

    double GetSum();
    double GetDSum();

//  private :
//    double Max_Discount(double sum);
};


#endif
